# encoding: UTF-8
'''
Created on 2013年11月7日

@author: xuben

军资
'''

from ..common import Command, Logger, RequestModel
from ..common.SocketService import gameSocketService
import ResourceData

class NationFeedGetInfoRequest(RequestModel.RequestModel):
    '''
    classdocs
    '''
    
    def setCommand(self):
        self.command = Command.GET_NATION_FEED_INFO
        
    def onReceive(self, data):
        ResourceData.updateNationFeed(data)
        
'''
领取军资
'''
def getNationFeed():
    command = Command.GET_NATION_FEED
    params = ''
    gameSocketService.send(command, params, getNationFeedCallback)
    
'''
领取军资回调函数
'''
def getNationFeedCallback(data):
    if 'rewards' in data:
        for rewardObj in data['rewards']:
            if 'type' in rewardObj and 'value' in rewardObj:
                Logger.log('领取军资, type:' + str(rewardObj['type']) + ', num:' + str(rewardObj['value']), output = True)